package com.trade.wzj.service.xiang;

import java.util.List;

import com.trade.wzj.dao.xiang.ClientOrderinfoDetailsDao;
import com.trade.wzj.model.xiang.ClientOrderinfoDetails;
import com.trade.wzj.model.xiang.CompanyPurchaseDetails;
import com.trade.wzj.model.xiang.CompanyPurchaseInfo;

public class ClientOrderinfoDetailsimpl implements ClientOrderinfoDetailsService {
	private ClientOrderinfoDetailsDao mapper;

	public ClientOrderinfoDetailsDao getMapper() {
		return mapper;
	}

	public void setMapper(ClientOrderinfoDetailsDao mapper) {
		this.mapper = mapper;
	}
	/*
	 * (non-Javadoc)客户订单添加详情方法
	 * @see com.trade.wzj.service.xiang.ClientOrderinfoDetailsService#ClientOrderinfoDetailsAdd(com.trade.wzj.model.xiang.ClientOrderinfoDetails)
	 */
	@Override
	public int ClientOrderinfoDetailsAdd(List<ClientOrderinfoDetails> clientorderinfodetails) throws Exception {
		
			int result = mapper.ClientOrderinfoDetailsAdd(clientorderinfodetails);
			if(result >0) {
				System.out.println("添加成功");
			}
	
		return result;
	}

	

	//生成公司采购单
	@Override
	public List<ClientOrderinfoDetails> getCompanyOrderMethod(Integer[] clientQuotaID) throws Exception {
		List<ClientOrderinfoDetails> list=null;
		try {
			
				list=mapper.getCompanyOrderMethod(clientQuotaID);
			
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

	//添加公司采购单内容
	@Override
	public void addCompanyPurchaseInfo(CompanyPurchaseInfo companyInfo) throws Exception {
		try {
			//调用添加公司采购单内容方法
			mapper.addCompanyPurchaseInfo(companyInfo);
		} catch (Exception e) {
			throw new Exception();
		}
		
	}

	//添加公司采购单内容详情
	@Override
	public void addCompanyPurchaseDetail(List<CompanyPurchaseDetails> list) throws Exception {
		try {
			mapper.addCompanyPurchaseDetail(list);
		} catch (Exception e) {
			throw new Exception();
		}
	}

	//通过公司采购编号查询采购信息
	@Override
	public List<CompanyPurchaseInfo> getAllCompanyPurchaseInfo(String purchaseNo) throws Exception {
		List<CompanyPurchaseInfo> list=null;
		try {
			if(null!=purchaseNo) {
				list=mapper.getAllCompanyPurchaseInfo(purchaseNo);
			}
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

	//根据采购编号和供应商编号查询采购详情信息
	@Override
	public List<CompanyPurchaseDetails> getAllCompanyPurchaseInfos(Integer companyPurchaseInfoID,
			Integer DetailsupplierId, String productName) throws Exception {
		List<CompanyPurchaseDetails> list=null;
		try {
			list=mapper.getAllCompanyPurchaseInfos(companyPurchaseInfoID, DetailsupplierId, productName);
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

	//通过采购id和供应商编号id查询采购编号和采购日期
	@Override
	public CompanyPurchaseInfo getCompanyPurchaseId(Integer id, Integer supplierId)throws Exception {
		CompanyPurchaseInfo companyPurchaseInfo=null;
		try {
			companyPurchaseInfo=mapper.getCompanyPurchaseId(id, supplierId);
		} catch (Exception e) {
			throw new Exception();
		}
		return companyPurchaseInfo;
	}

	//查询客户订单详情
	@Override
	public List<ClientOrderinfoDetails> getClientOrderDetail(Integer clientQuotaID, String productName)
			throws Exception {
		List<ClientOrderinfoDetails> list=null;
		try {
			if(null!=clientQuotaID) {
				list=mapper.getClientOrderDetail(clientQuotaID, productName);
			}else {
				throw new Exception();
			}
		} catch (Exception e) {
			throw new Exception();
		}
		return list;
	}

}
